home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
001a
/
tlxutl10.zip
/
SETCOL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-01-25
|
2KB
|
101 lines
Program SetColours;
{ Copyright 1991 By Reuben Sumner }
Uses
Dos;
Const
LookFor : Array [1..12] of String[10] =
('deffg','defbg','statfore','statback','bord','mbord','mbback',
'mfore','mbold','mback','mbar','msel');
{ This is an array of strings to search for in config file that indicate
that they are colours }
Var
Config, Salt : PathStr;
CNF, SLT, New : Text;
Colours : Array [1..12] of Byte;
FDir : DirStr;
FName : NameStr; { Strings for breaking up filenames }
FExt : ExtStr;
Line : String[80]; { Line to read in from files }
Temp : String[3];
Count, Position : Byte; { Count : For loop purposes
Position : variable for location of = sign
and other }
Name : String[10]; { Name of line in config ie "bord" }
Value : String[40]; { Value for Name ie 10 or "ATDT" }
Error : Integer; { Result code for Val procedure }
Begin
If ParamCount <> 2 Then Begin
WriteLn ('Improper syntax!');
WriteLn;
WriteLn ('Correct syntax is:');
WriteLn ('SETCOL [config[.CNF] file[.SLT]]');
End
Else Begin
Config := ParamStr (1);
Salt := ParamStr (2);
FSplit (Config,FDir,FName,FExt);
If FExt = '' Then
FExt := '.CNF';
Config := FDir + FName + FExt;
Assign (CNF,Config);
Reset (CNF);
FSplit (Salt,FDir,FName,FExt);
If FExt = '' Then
FExt := '.SLT';
Salt := FDir + FName + FExt;
Assign (SLT,Salt);
FSplit (Salt,FDir,FName,FExt);
FExt := 'bak';
Assign (New,FDir+FName+'.'+FExt);
{$I-}
Erase (New);
{$I+}
Error := IOResult; { Never used but clears result code }
Assign (New,Salt);
Rename (SLT,FDir+FName+'.'+FExt);
Repeat
ReadLn (CNF,Line);
Count := 1;
Position := Pos ('=',Line);
Name := Copy (Line,1,Position-1);
Value := Copy (Line,Position+1,Length(Line)-Position);
Repeat
If Name = LookFor [Count] Then Begin
Val (Value,Colours[Count],Error);
Count := 12;
End;
Inc (Count);
Until Count = 13;
Until Eof(CNF);
Close (CNF);
Reset (SLT);
Rewrite (New);
Repeat
ReadLn (SLT,Line);
Repeat
Position := Pos (#1,Line);
If Position <> 0 Then Begin
Str (Colours[Ord(Line[Position+1])],Temp);
Delete (Line,Position,2);
Insert (Temp,Line,Position);
End;
Until Position = 0;
WriteLn (New,Line);
Until Eof (SLT);
Close (New);
Close (SLT);
End;
End.